<?php

namespace App\Http\Controllers\Long;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Request;

class BaseController extends Controller
{
    public $searchParams;
    public function __construct()
    {
        $this->middleware('authLogin');
        parent::__construct();
    }

    public function getPageOffset($page_name=null){
        $page_name = $page_name ? $page_name : 'page';
        $offset = 0;
        if(isset($_GET[$page_name]) && $_GET[$page_name]){
            $current_page = $_GET[$page_name] + 0;
            $offset = ($current_page-1)*config('constant.pageSize');
        }
        return $offset;
    }

    public function getCurrentPage($page_name=null){
        $page_name = $page_name ? $page_name : 'page';
        $currentPageShow = 1;
        if(isset($_GET[$page_name]) && $_GET[$page_name]){
            $currentPageShow = $_GET[$page_name] + 0;
        }
        return $currentPageShow;
    }

    public function getSearchParams(){
        $this->searchParams = $_GET;
    }

    public function formatDate($data){
        $u_time = strtotime($data) + 86399;
        return date('Y-m-d H:i:s' , $u_time);
    }

}
